/*
 * Copyright 2007 Xplayat, S.L. All rights reserved.
 * Propiedad de Xplayat. 
 */
package es.xpt.ysf.view;

import es.xpt.ysf.logging.LogManager;
import es.xpt.ysf.utils.JNDINames;
import es.xpt.ysf.utils.ServiceLocator;
import es.xpt.ysf.utils.ServiceLocatorException;
import es.xpt.ysf.view.model.UserBean;

public abstract class LocalDelegate<L> {

  private UserBean userBean = null;
  private ServiceLocator sl;

  public LocalDelegate(UserBean user) {
    userBean = user;
    try {
		sl = new ServiceLocator(userBean);
	} catch (ServiceLocatorException e) {
		LogManager.getLog(getClass()).error(e.getMessage(), e);
	}
  }
  
  /*
   * en los delegate siempre hay un metodo connect para realizar la
   * conexion al ejb correspondiente
   */
  @SuppressWarnings("unchecked")
  protected L connect(JNDINames localName) throws ServiceLocatorException {
    return (L)sl.getLocal(localName);
  }
  

  public UserBean getUserBean() {
    return userBean;
  }
}
